package com.beemans.topon.demo

import com.beemans.common.app.CommonApp
import com.beemans.topon.TopOn
import com.beemans.topon.data.*
import com.beemans.topon.demo.constant.Constant

/**
 * @author tiamosu
 * @date 2020/7/2.
 */
@Suppress("unused")
class MyApp : CommonApp() {

    override fun initConfigurator() {
    }

    override fun initSDK(isMainProcess: Boolean) {
        super.initSDK(isMainProcess)
        if (isMainProcess) {
            //约定以Key
            val customKeyResponse = CustomKeyResponse(channel = "huawei")
            //全局
            val globalCustom = CustomResponse(
                customKeyResponse,
                mutableMapOf<String, String>().apply { put("custom", "aa") })
            //Placement
            val placementCustom = PlacementCustomResponse(
                Constant.NATIVE_ID,
                customKeyResponse,
                mutableMapOf<String, String>().apply { put("custom", "bb") })

            val privacyConfig = PrivacyConfig().apply {
                setDeniedDeviceInfo(*PrivacyConfig.defaultDeviceInfoArr)
                setTtCustomController(PrivacyConfig.defaultTtController)
                setGdtCustomController(PrivacyConfig.defaultGdtController)
                setBdCustomController(PrivacyConfig.defaultBdController)
            }
            val tpConfig = TpConfig(
                Constant.APP_ID,
                Constant.APP_KEY,
                BuildConfig.DEBUG,
                globalCustom,
                listOf(placementCustom),
                isOpenDirectDownload = false,
                isPersonalizedAds = true,
                privacyConfig = privacyConfig,
            )
            TopOn.init(this, tpConfig)
        }
    }
}